Update ToWkt::write_wkt to not buffer string#126
Merged
michaelkirk merged 6 commits intomainfrom Nov 27, 2024
Merged
Conversation
geo_types writer integration to avoid intermediate representationToWkt::write_wkt to not buffer string
Member
Author
|
I updated the PR description. This is actually considerably faster than collecting a string and then writing that to the output buffer. |
kylebarron
commented
Nov 26, 2024
Member
Author
kylebarron
left a comment
There was a problem hiding this comment.
I'd say I'm content with keeping the direct APIs as using std::fmt::Write because we know we're writing UTF8 content. Otherwise you'd have to write to a Vec<u8> and then parse that back to a String (or maybe trust ourselves and use from_utf8_unchecked?)
src/to_wkt/mod.rs
Outdated
Comment on lines
+17
to
+18
| // Sadly, this will lose the content of the error when mapping to std::fmt::Error | ||
| self.0.write(s.as_bytes()).map_err(|_| std::fmt::Error)?; |
Member
Author
There was a problem hiding this comment.
This loss of error content is unfortunate but I'm not sure of a good way around this.
Retain io::error details
michaelkirk
approved these changes
Nov 27, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGES.mdif knowledge of this change could be valuable to users.This avoids buffering when writing WKT to
std::io::Write. It's considerably faster: